package com.tchintech.pay;

import android.content.Context;
import android.support.multidex.MultiDexApplication;

import com.tchintech.pay.model.entity.Memberinfo;
import com.tchintech.pay.utils.ToastUtils;

import cn.jpush.android.api.JPushInterface;


/**
 * <Pre>
 * </Pre>
 *
 * @author
 * @version 1.0
 *          <p/>
 *          Create by 2016/1/27 10:47
 */
public class MyApplication extends MultiDexApplication {
    private static MyApplication instance;

    public static String cacheDir = "";
//    private RefWatcher refWatcher;
    // TelephonyManager telephonymanager = ((TelephonyManager) getSystemService(TELEPHONY_SERVICE));


    //登陆后的警员类
    private Memberinfo memberinfo;
    private boolean hasyujing;


    @Override
    public void onCreate() {
        super.onCreate();

        instance = (MyApplication) getApplicationContext();
//        this.enabledStrictMode();
        ToastUtils.register(this);

        //LeakCanary检测OOM 华为X2 6.0 后内存泄漏.
        //  LeakCanary.install(this);

        //初始化日志输出工具
//        CrashHandler.init(new CrashHandler((MyApplication) getApplicationContext()));
        /**
         * 如果存在SD卡则将缓存写入SD卡,否则写入手机内存
         */

        if (getApplicationContext().getExternalCacheDir() != null && isExistSDCard()) {
            cacheDir = getApplicationContext().getExternalCacheDir().toString();

        } else {
            cacheDir = getApplicationContext().getCacheDir().toString();
        }


    }

    private boolean isExistSDCard() {
        if (android.os.Environment.getExternalStorageState().equals(android.os.Environment.MEDIA_MOUNTED)) {
            return true;
        } else {
            return false;
        }
    }


    public static MyApplication getInstance() {
        return instance;
    }

    // 获取ApplicationContext
    public static Context getContext() {
        return instance;
    }


    public Memberinfo getMemberinfo() {
        return memberinfo;
    }

    public void setMemberinfo(Memberinfo memberinfo) {
        this.memberinfo = memberinfo;
    }

    public boolean isHasyujing() {
        return hasyujing;
    }

    public void setHasyujing(boolean hasyujing) {
        this.hasyujing = hasyujing;
    }


}
